package com.itheima.crm.service;




import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.itheima.common.utils.Page;
import com.itheima.crm.mapper.GongGaoDao;

import com.itheima.crm.pojo.gonggao;

import com.itheima.crm.service.gonggaoService;

/**
 * 客户管理
 * 
 * @author lx
 *
 */
@Service
public class gonggaoServiceImpl implements gonggaoService {

	
	@Autowired
	private GongGaoDao gonggaodao;
	@Override
	public Page<gonggao> selectgonggao(String fromtime,String totime,gonggao vo) {
		Page<gonggao> page = new Page<gonggao>();
		// 每页数
		page.setSize(5);
		vo.setSize(5);
		if (null != vo) {
			// 判断当前页
			if (null != vo.getPage()) {
				page.setPage(vo.getPage());
				vo.setStartRow((vo.getPage() - 1) * vo.getSize());
			}

			// 总条数
			page.setTotal(gonggaodao.gonggaoCount(fromtime,totime,vo));
			
			page.setRows(gonggaodao.selectgonggao(fromtime,totime,vo));
			 
		}
		return page;
		
	}

	@Override
	public gonggao selectgonggaoById(Integer id) {
		return gonggaodao.selectgonggaoById(id);
		
	}

	@Override
	public void insertgonggao(gonggao gonggao) {
	gonggaodao.insertgonggao(gonggao);
		
	}

	@Override
	public void updategonggaoById(gonggao gonggao) {
		gonggaodao.updategonggaoById(gonggao);
		
	}

	@Override
	public void deletegonggao(Integer id) {
		// TODO Auto-generated method stub
		gonggaodao.deletegonggaoById(id);
	}

	@Override
	public void changeShow(String ifshow, Integer id) {
		gonggaodao.changeShow(ifshow, id);
		
	}

	@Override
	public Page<gonggao> selectgonggaoAll(gonggao vo) {
		Page<gonggao> page = new Page<gonggao>();
		// 每页数
		page.setSize(5);
		vo.setSize(5);
		if (null != vo) {
			// 判断当前页
			if (null != vo.getPage()) {
				page.setPage(vo.getPage());
				vo.setStartRow((vo.getPage() - 1) * vo.getSize());
			}

			// 总条数
			page.setTotal(gonggaodao.gonggaoCountAll(vo));
			
			page.setRows(gonggaodao.selectgonggaoAll(vo));
			
			
		}
		
		List<gonggao> a=gonggaodao.selectgonggaoAll(vo);
		 
		 for(int i=0;i<a.size();i++) {
		 gonggao gong= a.get(i);
		 
		 
		 System.out.println(gong.getUpdatetime());
		 }
		return page;
	}


	




}
